<style type="text/css">
    .demo-upload-list {
        display: inline-block;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        border: 1px solid transparent;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
        position: relative;
        box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
        margin-right: 4px;
    }

    .demo-upload-list img {
        width: 100%;
        height: 100%;
    }

    .demo-upload-list-cover {
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, .6);
    }

    .demo-upload-list:hover .demo-upload-list-cover {
        display: block;
    }

    .demo-upload-list-cover i {
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }
</style>
<template>
    <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100">
        <Form-item label="地址" prop="address">
            <i-input v-model="formValidate.address" placeholder="请输入岗位地址"></i-input>
        </Form-item>
        <Form-item label="电话" prop="phone">
            <i-input v-model="formValidate.phone" placeholder="请输入岗位电话"></i-input>
        </Form-item>
        <Form-item label="摄像头信息" prop="Camerainfos">
            <i-input v-model="formValidate.Camerainfos" placeholder="请输入摄像头信息"></i-input>
        </Form-item>
        <Form-item label="级别" prop="Gangweilevel">
            <i-select v-model="formValidate.Gangweilevel" placeholder="请选择级别">
                <i-option value="1">1</i-option>
                <i-option value="2">2</i-option>
                <i-option value="3">3</i-option>
                <i-option value="4">4</i-option>
                <i-option value="5">5</i-option>
                <i-option value="6">6</i-option>
            </i-select>
        </Form-item>
        <Form-item label="人员数" prop="Personcount">
            <i-input v-model="formValidate.Personcount" placeholder="请输入人员数量"></i-input>
        </Form-item>
        <Form-item label="岗位描述" prop="Description">
            <i-input v-model="formValidate.Description" placeholder="请输入岗位描述"></i-input>
        </Form-item>
        <Form-item>
            <i-button @click="handleSubmit('formValidate')" type="primary">提交</i-button>
            <i-button type="ghost" style="margin-left: 8px">取消</i-button>
        </Form-item>
    </i-form>
</template>
<script>
    import apiUtil from '../../assets/utils/api_util';

    export default {
        data() {
            return {
                formValidate: {
                    //添加字段
                    address: '',
                    phone: '',
                    Gangweilevel: '',
                    Camerainfos: '',
                    Personcount:'',
                    Description:'',
                },
                ruleValidate: {
                    address: [
                        {required: true, message: '地址不能为空', trigger: 'blur'}
                    ],
                    phone: [
                        {required: true, message: '电话不能为空', trigger: 'blur'},
                    ],
                    Gangweilevel: [
                        {required: true, message: '请选择级别', trigger: 'change'}
                    ],
                    Camerainfos: [
                        {required: true, message: '摄像机信息不能为空', trigger: 'blur'}
                    ],
                    Personcount: [
                        {required: true, message: '人员数量不能为空', trigger: 'blur'}
                    ],
                },
            }
        },
        mounted: function () {
            this.getPaperData();
        },

        methods: {
            changeOutDate: function (date) {
                console.log(date);
                this.formValidate.outdate = date;
            },
            handleSubmit(name) {

                let that = this;
                let model = this.$refs[name].model;
                this.$refs[name].validate((valid) => {
                    that.addData(model);
                })
            },
            //添加
            addData: function (model) {
                let that = this;

                let params = that.$qs.stringify(model);
                this.$Loading.start();

                apiUtil.post(that,apiUtil.urls.StationCreate, params, function (res) {
                    that.$Loading.finish();

                    that.$Notice.open({
                        title: '通知',
                        desc: '添加成功 ',
                        duration: 0
                    });

                });
            },

            uploadList() {
                let that = this;
                this.imageList = that.$refs.upload ? that.$refs.upload.fileList : [];
                console.log('this.imageList:', this.imageList);
                // return ;
            },

        }
    }
</script>
